<template>
    <div class="song-list">
        <div class="list">
            <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onload">

                <div v-for="(item, index)  in list" :key="index">
                    <h4>{{ item.name }}</h4>
                    <div class="singer">
                        <span v-for="(singer, index) in item.singer" :key="singer.id">
                            {{ singer.name }}
                            <span v-show="index != item.singer.length - 1">/</span>
                        </span>
                        <span v-show="item.album">
                            <span>.</span>
                            <span v-for="(album, index) in item.album.name " :key="index">{{ album }}</span>
                        </span>
                        <span v-show="item.album.subtitle">
                            <span>.</span>
                            {{ item.album.subtitle }}
                        </span>

                    </div>
                </div>
            </van-list>
        </div>
    </div>
</template>

<script>

export default {
    props: ["singerid"],

    data() {
        return {

            list: [],
            loading: false,
            finished: false,
            page: 1,

        }
    },

    created() {
        this.getData(this.singerid, 1, 10)
    },
    methods: {
        getData() {
            this.$request("get", "/singer/songs?singermid=" + this.singerid + "&page=" + this.page + "&num30")
                .then((res) => {
                    console.log(res);
                    this.list = this.list.concat(res.data.list);
                    this.loading = false;
                    this.page++;
                    if (res.data.list.length == 0) {
                        this.finished = true
                    }
                })
        },
        onload() {
            setTimeout(() => {
                this.getData();
                this.loading = true;
            }, 1000);
        }
    }

}
</script>
<style  scoped>
header>img {
    border-radius: 1rem;
    width: 50%;
}

.nick {
    overflow: hidden;
    display: flex;
    /** 弹性布局 */
    justify-content: center;
    /** 弹性布局中的内容水平居中 */
    align-items: center;
    /** 弹性布局中的内容垂直居中 */
    margin-bottom: 1rem;
}

.nick>img {
    height: 2rem;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.nick>span {
    height: 2rem;
    font-size: 0.8rem;
    line-height: 2rem;
}

.list {
    margin: 0 1rem;
}

.list h4 {
    text-align: left;
    font-size: 1rem;
}

.singer {
    text-align: left;
}

.singer span {
    font-size: 0.8rem;
    color: rgb(160, 160, 190);
}

.singer>span:nth-last-child(1)>span:nth-child(1) {
    color: red;
    font-weight: 900;
    padding: 0 0.5rem;
}

.singer>span:nth-last-child(2)>span:nth-child(1) {
    color: red;
    font-weight: 900;
    padding: 0 0.5rem;
}
</style>